package threadUtils;

import java.util.concurrent.CountDownLatch;

/**
 * @program: javase
 * @description: CountDownLatch 减法计数器
 * @author: lld
 * @create: 2021-04-18 19:43
 **/
public class CountdownLatchTest {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(10);
        for (int i = 0; i < 10; i++) {
            new Thread(() -> {
                System.out.println(Thread.currentThread().getName() + "走了");
                countDownLatch.countDown();
            }, String.valueOf(i)).start();
        }
//        只有计数器到0才往下执行
        countDownLatch.await();

        System.out.println("克里斯关下门");
    }

}
